<template>
	<view class="content" v-if="userInfo.hasOwnProperty('writer_user_config')">
		<u-navbar bgColor="#fff" :placeholder="true" :fixed="true" @leftClick="$back" title="约文须知" titleStyle="{'color': '#000'}">
			
		</u-navbar>
		<view class="baibox">
			<view class="baili">
				<view class="zhan">
					个人说明
				</view>
				<input type="text" class="put" maxlength="50" v-model="userInfo.writer_user_config.personal_note" placeholder="例：常规类的文案创作工期大约2-3天/单，不接受催稿">
			</view>
			<view class="baili">
				<view class="zhan">
					沟通时间
				</view>
				<input type="text" class="put"  maxlength="50" v-model="userInfo.writer_user_config.communication_time" placeholder="例：上午09：00-12：00  下午14：00-18：00">
			</view>
			<view class="baili">
				<view class="zhan">
					价格明细
				</view>
				<input type="text" class="put"  maxlength="50" v-model="userInfo.writer_user_config.remuneration_details" placeholder="例：古文600币/千字  定制类600币/千字 特殊需求另算">
			</view>
			<view class="baili">
				<view class="zhan">
					下单须知
				</view>
				<input type="text" class="put"  maxlength="50" v-model="userInfo.writer_user_config.order_notice" placeholder="例：下单后请积极与我沟通细节，制作过程中保证可随时联系">
			</view>
			<view class="baili">
				<view class="zhan">
					版权归属
				</view>
				<input type="text" class="put"  maxlength="50" v-model="userInfo.writer_user_config.publication_works" placeholder="请输入版权归属">
			</view>
			<view class="baili">
				<view class="zhan">
					<!-- 额外备注 -->
					额外备注
				</view>
				<input type="text" class="put"  maxlength="100" v-model="userInfo.writer_user_config.additional_remarks" placeholder="请输入额外备注">
			</view>
		</view>
		<view class="ti" @click="submit()">
			确认编辑
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				userInfo:{}
			}
		},
		onShow() {
			this.getUserInfo()
		},
		methods: {
			submit(){
				var prams = {
					personal_note:this.userInfo.writer_user_config.personal_note,
					communication_time:this.userInfo.writer_user_config.communication_time,
					remuneration_details:this.userInfo.writer_user_config.remuneration_details,
					order_notice:this.userInfo.writer_user_config.order_notice,
					publication_works:this.userInfo.writer_user_config.publication_works,
					additional_remarks:this.userInfo.writer_user_config.additional_remarks
				}
				if(prams.personal_note === '' || prams.personal_note === null){
					this.$common.errorToShow('请输入个人说明')
					return
				}
				
				
				if(!prams.communication_time){
					this.$common.errorToShow('请输入沟通时间')
					return
				}
			
				if(!prams.remuneration_details){
					this.$common.errorToShow('请输入价格明细')
					return
				}
				if(!prams.order_notice){
					this.$common.errorToShow('请输入下单须知')
					return
				}
				if(!prams.publication_works){
					this.$common.errorToShow('请输入版权归属')
					return
				}
				if(!prams.additional_remarks){
					this.$common.errorToShow('请输入额外备注')
					return
				}
				
				if(!this.userInfo.writer_user_config.hasOwnProperty('uid')){
					prams['uid'] = this.userInfo.writer_user_config.uid
				}
				
				
				this.$api.default.request('user/saveWriterUserConfig', prams).then((res) => {
					if (res.code == 1) {
						this.$common.successToShow(res.msg,()=>{
							uni.navigateBack()
						})
					}
				})
			},
			getUserInfo(){
				this.$api.default.request('user/userInfo', {},'POST',false).then((res) => {
					if (res.code) {
						this.userInfo = res.user
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: rgba(242, 245, 242, 1);
	}

	.content {
		padding-top: 20rpx;

		.baibox {
			background-color: #FFFFFF;
			padding: 0 30rpx;
			margin-bottom: 20rpx;

			.baili:last-child {
				border: none;
			}

			.baili {
				height: 120rpx;
				border-bottom: 1px solid rgba(153, 153, 153, 0.1);

				.zhan {
					font-size: 28rpx;
					font-weight: bold;
					letter-spacing: 0em;
					color: #3D3D3D;
					line-height: 40rpx;
					padding: 20rpx 0 8rpx;
				}

				.put {
					font-size: 24rpx;
					font-weight: normal;
					letter-spacing: 0em;
					line-height: 34rpx;
					color: #3D3D3D;
				}
			}
		}

		.ti {
			width: 690rpx;
			height: 86rpx;
			border-radius: 8px;
			line-height: 86rpx;
			margin: 0 auto;
			opacity: 1;
			background: #45C4B0;
			font-size: 32rpx;
			font-weight: bold;
			text-align: center;
			letter-spacing: 0em;
			color: #FFFFFF;
		}
	}
</style>